package com.atguigu.flink.chapter05.Source;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.ArrayList;
import java.util.Arrays;

/**
 * TODO
 *
 * @author cjp
 * @version 1.0
 * @date 2021/1/20 10:26
 */
public class Flink01_Source_Collection {
    public static void main(String[] args) throws Exception {
        // 1. 获取执行环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);

        // TODO 从集合读取数据
        DataStreamSource<Integer> collectionDS = env.fromCollection(Arrays.asList(1, 2, 3, 4, 5));
        DataStreamSource<Integer> elementDS = env.fromElements(11, 22, 33, 44, 55);

        collectionDS.print("collection");
        elementDS.print("element");

        env.execute();
    }
}
